/*
 * 
 *  
 */
Ext.namespace("Ext.ux");

Ext.ux.InfoBar = function(config){
	this.autoEl = { tag: 'div',	cls: 'cls-infobar', tabIndex: -1};
	this.height = 22;
	Ext.Container.prototype.constructor.call(this,config);
};

Ext.extend( Ext.ux.InfoBar, Ext.Container, {
	elements: 'pathArea, rightArea',
	topLine: 0,

	pathAreaCls: 'cls-infobar-path',
	rightAreaCls: 'cls-infobar-right',
	
	pathAreaWidth: 800,
	rightAreaWidth: 500,

	pathPromptText: '当前位置：',	
	pathCurrentText: '首页',	
	orgText: '',
	empText: '',

    initComponent : function(){
        Ext.ux.InfoBar.superclass.initComponent.call(this);
    },
    
	onRender: function(ct, position){
        Ext.ux.InfoBar.superclass.onRender.call(this, ct, position);
        
		this.getId();
		this.setHeight(this.height);
		this.el.unselectable();
		
		//initiate pathPrompt	
		if( !this.pathArea ){
			this.createElement( 'pathArea', this.el.dom );
		}
		this.pathArea.setLeftTop(0, this.topLine);
		this.pathArea.setSize( this.pathAreaWidth, this.height);

		if( !this.rightArea ){
			this.createElement( 'rightArea', this.el.dom );
		}

		this.setCurrentPath( this.pathCurrentText );
		
	},
	
    createElement : function(name, pnode){
        if(this[name]){
            pnode.appendChild(this[name].dom);
            return;
        }
        if(this.elements.indexOf(name) != -1){
            var el = document.createElement('div');
			el.id = pnode.id + '-' + name;
            el.className = this[name+'Cls'];
            this[name] = Ext.get(pnode.appendChild(el));
		}
	},
	
    onResize : function( w, h){
        if(w !== undefined || h !== undefined){
			if(typeof w == 'number'){
				this.rightArea.setWidth( this.rightAreaWidth );
				this.rightArea.setLeftTop( w-this.rightAreaWidth, this.topLine);
			}
        }
    },
    
    setCurrentPath : function( t ){
		this.pathArea.dom.innerHTML = "<label class='cls-infobar-path-prompt'>"+ this.pathPromptText +"</label>" + "<label class='cls-infobar-path-value'>"+ t +"</label>";
		this.pathCurrentText = t;
	},
	
    refreshRightArea : function(){
		this.rightArea.dom.innerHTML = "<label class='cls-infobar-right-org'>"+this.orgText +"</label>" + "<label class='cls-infobar-right-emp'>"+this.empText +"</label>";
	}
});